home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / PGM_TOOL / PREVIEW / CLP2DLFI / README.TXT < prev    next >
Text File  |  1995-11-11  |  5KB  |  144 lines

  1.  
  2. ReadMe.txt file from Clp2Dlfi directory
  3.  
  4. Author: Brad Tharalson, CIS 72030,3045
  5.  
  6. This file briefly describes using the ToDelphi.dpr project file to
  7. convert xBase style code to Delphi code.
  8.  
  9. As usual, make backups before starting, however, the code is not supposed
  10. to change any existing files.
  11.  
  12. Before running this program, see the DBFDIRS.TXT file, add/change the
  13. directories listed there to point to some of your test DBF directories,
  14. the field info will be loaded for all DBF's in these directories, the files
  15. are not changed in any way.
  16.  
  17. My own file contains the following database directories in DBFDIRS.TXT:
  18.  
  19.   \accting\comdat
  20.   \accting\jcdat
  21.   \accting\ardat
  22.   \accting\apdat
  23.   \accting\gldat
  24.  
  25. After loading the ToDelphi project, use "Build All" the first time.
  26. If you try to run it immediately, it will tell you it can't find BTprint.pas.
  27.  
  28. This program has two options to it, one translates PRG files to PAS files, the
  29. other translates DBF database files to PAS code that can be included in your
  30. code.  The "Options" menu of the "Translate xBase Code" form allows you to
  31. select which type you want to do.
  32.  
  33. PRG to PAS Conversion
  34. ---------------------
  35.  
  36. First Step: Convert xBase code to dBase for Windows Style, this code
  37.             comes from a routine I wrote several months ago and can
  38.             be found in the dBase for Windows (DBW) forum.
  39. Second Step: Convert DBW code to Delphi code.
  40.  
  41. Select "Translate xBase Code" on main "File" menu choice.
  42. When it opens it starts in the directory where the install took place.
  43. It will show one PRG file (tf.prg), this is a test file, double-click
  44. on this to start processing, it is about 200 lines.  When done, you
  45. will see a file TEST.PAS in the right list box with a star next to it.
  46. If you double-click on this item, the converted code will appear along
  47. with the intermediate DBW code after it.
  48.  
  49. I have about one-hundred thousand lines of xBase code that I am converting
  50. to Delphi.
  51.  
  52. xBase code below (Print Customer Name List):
  53.  
  54.     use cust
  55.     set print on
  56.     set device to printer
  57.     line=0
  58.     do while .not. eof()
  59.       @ line,0 say cust->name
  60.       line=line+1
  61.       skip
  62.     enddo
  63.     set device to screen
  64.     set print off
  65.  
  66. The equivalent Delphi code using wPreview code and DBserver.pas is below:
  67.  
  68.     Uses DBFserver, CommonCode, LinePrinter;
  69.  
  70.     procedure CustLIst;
  71.     var lpp:Lpr;  { Lpr is in unit wPreview.pas }
  72.         tdb:oDB:  { from DBserver.pas unit in Clp2Dlfi directory }
  73.     begin
  74.       lpp:=Lpr.create;
  75.       tdb:=nil;
  76.       dbUse(tdb,'cust');  { open Cust.dbf }
  77.       with lpp do begin
  78.         SetDestination;
  79.         StartDoc(for8x11,'Customer List');
  80.         while not tdb.eof do begin
  81.           { have to use "lpp.writeln" because WriteLn is built-in to Delphi,
  82.             and it takes precedence if no qualifier }
  83.           lpp.writeln(tdb.s('cust'));
  84.         end;
  85.         StopDoc;
  86.       end;
  87.       dbClose(tdb);
  88.       lpp.free;
  89.     end;
  90.  
  91. Steps in Converting xBase Code to Delphi
  92. ----------------------------------------
  93.   With: <File>.prg
  94. Output: <File>.pas,  translated program source code
  95.         <File>.prv,  private variables
  96.         <File>.pub,  public variables
  97.         <File>.txt,  DBW intermediate code, can be deleted
  98.  
  99. Determine which routines are for user input and delete them
  100.   (these will have to be re-done in Delphi).
  101. Find all 'read' lines and delete the input lines, the vars filled by these
  102. routines will have to be passed in by the Window that calls it.
  103.  
  104. With <File>.prv and <File>.pub (if one) determine each type of variable
  105. by looking at code.
  106.  
  107. With resulting Delphi file, find the following and correct as needed:
  108.  
  109.      Check 'xx $ yy'  ==> pin(xx,yy) conversions for syntax errors.
  110.      Search for "YY", fix for-loop syntax, note: loop var must be local
  111.      Look for 'iif(' to 'iifi(', if params not integer, use iifs() or iifd()
  112.      Check occurances of Date() -> xDate, to see if DateMath() needs to be used.
  113.      Check for ascan(), convert to "for" loop.
  114.      Check syntax on str(), S/B str(aa,bb,cc) or str2(aa,bb)
  115.      Find "dbf." and substitute correct "oDB" var.
  116.      Search for ZZ of dbClose(ZZ) lines, change 'ZZ' to oDB var.
  117.  
  118. During compile: when using actual numbers in floating math
  119. or comparisons, must add leading zero (unless its just zero).
  120.    jj:=ii*.035  ==> jj:=ii*0.035;
  121.    if jj<.003 then ...  ==>  if jj<0.003 then ...
  122.  
  123. Search for procs, determine param and var types.
  124. Enter list of vars and arrays from <File>.prv into 'Private' section.
  125. Enter list of vars and arrays from <File>.pub into 'Public' section.
  126. 'CloseAll' should be changed to a series of dbClose() commands.
  127. Find occurances of and delete: Select, SelectArea.
  128. Find occurances of 'Alias', and delete or change to 'dbf.Alias'.
  129.  
  130.  
  131.  
  132. DBF to PAS Conversion
  133. ---------------------
  134.  
  135. This routine creates two files, <File>.int and <File>.imp for each <File>.dbf.
  136.  
  137. <File>.int is placed in the Interface section of your code.
  138. <File>.imp is placed in the Implementation section of your code.
  139.  
  140. See wEshippr.pas in the Samples directory for examples.
  141.  
  142. Good Luck
  143.  
  144.